<?php
/**
 * Update Model for Render  Component
 *
 */

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.model');
jimport( 'joomla.filesystem.file' );

/**
 * Render Update Model
 *
 */
class RendersModelUpdate extends JModel
{
	/**
	 * Constructor that retrieves the ID from the request
	 *
	 * @access	public
	 * @return	void
	 */
        var $gstr = null ;

	function __construct()
	{
		parent::__construct();

		
	}

	function buildData()
        {

               $str = '';
               $path=JPATH_COMPONENT.DS.'models'.DS.'server.ini';
               $db =& JFactory::getDBO();
               $query1 = ' SELECT * FROM #__news WHERE checked = 1';
               $query2 = ' SELECT * FROM #__slideshow WHERE public = 1';
               $query3 = ' SELECT * FROM #__listserver ';
               $query4 = ' SELECT * FROM #__listserver WHERE checked = 1 ';
               
               $db->setQuery($query1);
               $row1 = $db->loadRowList();
               
               $db->setQuery($query2);
               $row2 = $db->loadRowList();

               $db->setQuery($query3);
               $row3 = $db->loadRowList();

               $db->setQuery($query4);
               $row4 = $db->loadRowList();
               
               for ($i=0; $i< count($row); $i++)
               {
                    $arr=array();
                    $arr = $row[$i];
                    $str = "[".$i."]\n";
                    $str .= "id = \"".$arr[1]."\"\n";
                    $str .= "name = \"".$arr[2]."\"\n";
                    $str .= "alias = \"".$arr[3]."\"\n";
                    $str .= "limitccu = \"".$arr[4]."\"\n";
                    $str .= "activeserver = \"".$arr[5]."\"\n";
                    $str .= "btserver = \"".$arr[6]."\"\n";

                    //JFile::write('write.ini', $str);

                    $this->gstr .= $str;

               }
               //file_put_contents($path, $this->gstr) or die('Not');
               return $row4 ;
        }

}